package com.popo.android.until;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.RandomAccessFile;
import java.io.Reader;
import java.util.*;

import android.graphics.Path.FillType;

public class FileDemo {
	public static void main(String[] args) {
		System.out.println("hhoo");
		File file = new File("adb.txt");
		InputStreamReader reader = null;
		BufferedReader br = null;

		if (file.exists()) {
			try {
				reader = new InputStreamReader(new FileInputStream(file));
				br = new BufferedReader(reader);
				String line = null;
				try {
					while ((line = br.readLine()) != null) {

					}
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} finally {

				try {
					reader.close();
					br.close();
				} catch (Exception e) {
					// TODO: handle exception
				}
			}
		} else {

			try {
				RandomAccessFile afile = new RandomAccessFile(file, "rw");

				afile.seek(file.length());
				afile.writeChars("");
				String sss = "aaa\n";
				sss.replace("\n", "");
				sss.trim();
				String[] ax = sss.split(" ");
				sss.equals("aa");
				int a = ax.length;
				afile.close();
				FileWriter filew = new FileWriter(file, true);
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}

		}
	}
}
